---
feature_name: Audio / Media Session
chrome_version: 57
feature_id: 5639924124483584
check_min_version: true
index: index.html
---

<h3>Background</h3>
<p>The <a href="https://developers.google.com/web/updates/2017/02/media-session">Media Session API</a> 
lets you customize media notifications by providing metadata information for
the media your web app is playing. It also allows you to handle media related
events such as seeking or track changing which may come from notifications or
media keys.</p>

<p>Credits: Media files are the works of <a href="http://www.wavemage.com/category/music/">Jan Morgenstern</a> and
licensed under <a href="https://creativecommons.org/licenses/by-nc-nd/3.0/">CC BY-NC-ND 3.0</a>.</p>

<button id="playButton">▶ PLAY</button>

{% include output_helper.html %}

<script>
  if (!('mediaSession' in navigator)) {
    ChromeSamples.setStatus('The Media Session API is not yet available. Try Chrome for Android.');
  }

  // This prevents unnecessary errors when Media Session API is not available.
  navigator.mediaSession = navigator.mediaSession || {};
  navigator.mediaSession.setActionHandler = navigator.mediaSession.setActionHandler || function() {};
  window.MediaMetadata = window.MediaMetadata || function() {};

  log = ChromeSamples.log;
</script>

{% include js_snippet.html filename='audio.js' %}

<script>
  document.querySelector('#playButton').addEventListener('click', onPlayButtonClick);
</script>
